<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: VIC20/VIC20.ino</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 VGA Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_v_i_c20_2_v_i_c20_8ino-example.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">VIC20/VIC20.ino</div>  </div>
</div><!--header-->
<div class="contents">
<p>Commodore VIC20 Emulator</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - www.fabgl.com</span></div><div class="line"><span class="comment">  Copyright (c) 2019 Fabrizio Di Vittorio.</span></div><div class="line"><span class="comment">  All rights reserved.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  This file is part of FabGL Library.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment">  it under the terms of the GNU General Public License as published by</span></div><div class="line"><span class="comment">  the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment">  (at your option) any later version.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div><div class="line"><span class="comment">  GNU General Public License for more details.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  You should have received a copy of the GNU General Public License</span></div><div class="line"><span class="comment">  along with FabGL.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;Preferences.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;WiFi.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;HTTPClient.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;esp_spiffs.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;esp_task_wdt.h&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabgl_8h.html">fabgl.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabutils_8h.html">fabutils.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;machine.h&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// embedded (free) games</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/blue_star.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/omega_fury.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/quikman.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/splatform.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/demo_birthday.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/arukanoido.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/demo_bah_bah_final.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/demo_digit.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/dragonwing.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/kikstart.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/kweepoutmc.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/nibbler.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/pooyan.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/popeye.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/pulse.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/spikes.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/tank_battalion.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/tetris_plus.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/astro-panic.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/frogger07.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/froggie.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;progs/embedded/tammerfors.h&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// non-free list</span></div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> *  LIST_URL    = <span class="stringliteral">&quot;http://cloud.cbm8bit.com/adamcost/vic20list.txt&quot;</span>;</div><div class="line">constexpr <span class="keywordtype">int</span> MAXLISTSIZE = 16384;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// root SPIFFS directory</span></div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> * ROOTDIR = <span class="stringliteral">&quot;/spiffs&quot;</span>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// name of embedded programs directory</span></div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> * EMBDIR = <span class="stringliteral">&quot;Free&quot;</span>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#define DEBUG 0</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>EmbeddedProgDef {</div><div class="line">  <span class="keywordtype">char</span> <span class="keyword">const</span> *    filename;</div><div class="line">  uint8_t <span class="keyword">const</span> * data;</div><div class="line">  <span class="keywordtype">int</span>             size;</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Embedded programs</span></div><div class="line"><span class="comment">//   To convert a PRG to header file use...</span></div><div class="line"><span class="comment">//         xxd -i myprogram.prg &gt;myprogram.h</span></div><div class="line"><span class="comment">//   ...modify like files in progs/embedded, and put filename and binary data in following list.</span></div><div class="line"><span class="keyword">const</span> EmbeddedProgDef embeddedProgs[] = {</div><div class="line">  { arukanoido_filename, arukanoido_prg, <span class="keyword">sizeof</span>(arukanoido_prg) },</div><div class="line">  <span class="comment">//{ demo_bah_bah_final_filename, demo_bah_bah_final_prg, sizeof(demo_bah_bah_final_prg) },</span></div><div class="line">  <span class="comment">//{ demo_digit_filename, demo_digit_prg, sizeof(demo_digit_prg) },</span></div><div class="line">  { dragonwing_filename, dragonwing_prg, <span class="keyword">sizeof</span>(dragonwing_prg) },</div><div class="line">  { kikstart_filename, kikstart_prg, <span class="keyword">sizeof</span>(kikstart_prg) },</div><div class="line">  { kweepoutmc_filename, kweepoutmc_prg, <span class="keyword">sizeof</span>(kweepoutmc_prg) },</div><div class="line">  { nibbler_filename, nibbler_prg, <span class="keyword">sizeof</span>(nibbler_prg) },</div><div class="line">  { pooyan_filename, pooyan_prg, <span class="keyword">sizeof</span>(pooyan_prg) },</div><div class="line">  { popeye_filename, popeye_prg, <span class="keyword">sizeof</span>(popeye_prg) },</div><div class="line">  { pulse_filename, pulse_prg, <span class="keyword">sizeof</span>(pulse_prg) },</div><div class="line">  { spikes_filename, spikes_prg, <span class="keyword">sizeof</span>(spikes_prg) },</div><div class="line">  { tank_battalion_filename, tank_battalion_prg, <span class="keyword">sizeof</span>(tank_battalion_prg) },</div><div class="line">  { tetris_plus_filename, tetris_plus_prg, <span class="keyword">sizeof</span>(tetris_plus_prg) },</div><div class="line">  <span class="comment">//{ blue_star_filename, blue_star_prg, sizeof(blue_star_prg) },</span></div><div class="line">  { demo_birthday_filename, demo_birthday_prg, <span class="keyword">sizeof</span>(demo_birthday_prg) },</div><div class="line">  { omega_fury_filename, omega_fury_prg, <span class="keyword">sizeof</span>(omega_fury_prg) },</div><div class="line">  { splatform_filename, splatform_prg, <span class="keyword">sizeof</span>(splatform_prg) },</div><div class="line">  { quikman_filename, quikman_prg, <span class="keyword">sizeof</span>(quikman_prg) },</div><div class="line">  { astro_panic_filename, astro_panic_prg, <span class="keyword">sizeof</span>(astro_panic_prg) },</div><div class="line">  { frogger07_filename, frogger07_prg, <span class="keyword">sizeof</span>(frogger07_prg) },</div><div class="line">  { froggie_filename, froggie_prg, <span class="keyword">sizeof</span>(froggie_prg) },</div><div class="line">  { tammerfors_filename, tammerfors_prg, <span class="keyword">sizeof</span>(tammerfors_prg) },</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#if DEBUG</span></div><div class="line"><span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">int</span>  scycles = 0;</div><div class="line"><span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">bool</span> restart = <span class="keyword">false</span>;</div><div class="line"><span class="keywordtype">void</span> vTimerCallback1SecExpired(xTimerHandle pxTimer)</div><div class="line">{</div><div class="line">  Serial.printf(<span class="stringliteral">&quot;%d - &quot;</span>, scycles / 5);</div><div class="line">  Serial.printf(<span class="stringliteral">&quot;Free memory (total, min, largest): %d, %d, %d\n&quot;</span>, heap_caps_get_free_size(0), heap_caps_get_minimum_free_size(0), heap_caps_get_largest_free_block(0));</div><div class="line">  restart = <span class="keyword">true</span>;</div><div class="line">}</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// where to store WiFi info, etc...</span></div><div class="line">Preferences preferences;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Main machine</span></div><div class="line">Machine machine;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> initSPIFFS()</div><div class="line">{</div><div class="line">  <span class="comment">// setup SPIFFS</span></div><div class="line">  esp_vfs_spiffs_conf_t conf = {</div><div class="line">      .base_path              = ROOTDIR,</div><div class="line">      .partition_label        = NULL,</div><div class="line">      .max_files              = 2,</div><div class="line">      .format_if_mount_failed = <span class="keyword">true</span></div><div class="line">  };</div><div class="line">  fabgl::suspendInterrupts();</div><div class="line">  esp_vfs_spiffs_register(&amp;conf);</div><div class="line">  fabgl::resumeInterrupts();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// copies embedded programs into SPIFFS</span></div><div class="line"><span class="keywordtype">void</span> copyEmbeddedPrograms()</div><div class="line">{</div><div class="line">  <span class="keyword">auto</span> dir = FileBrowser();</div><div class="line">  dir.setDirectory(ROOTDIR);</div><div class="line">  <span class="keywordflow">if</span> (!dir.exists(EMBDIR)) {</div><div class="line">    <span class="comment">// there isn&#39;t a EMBDIR folder, let&#39;s create and populate it</span></div><div class="line">    dir.makeDirectory(EMBDIR);</div><div class="line">    dir.changeDirectory(EMBDIR);</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <span class="keyword">sizeof</span>(embeddedProgs) / <span class="keyword">sizeof</span>(EmbeddedProgDef); ++i) {</div><div class="line">      <span class="keywordtype">int</span> fullpathlen = dir.getFullPath(embeddedProgs[i].filename);</div><div class="line">      <span class="keywordtype">char</span> fullpath[fullpathlen];</div><div class="line">      dir.getFullPath(embeddedProgs[i].filename, fullpath, fullpathlen);</div><div class="line">      FILE * f = fopen(fullpath, <span class="stringliteral">&quot;wb&quot;</span>);</div><div class="line">      <span class="keywordflow">if</span> (f) {</div><div class="line">        fwrite(embeddedProgs[i].data, 1, embeddedProgs[i].size, f);</div><div class="line">        fclose(f);</div><div class="line">      }</div><div class="line">    }</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>DownloadProgressFrame : <span class="keyword">public</span> uiFrame {</div><div class="line"></div><div class="line">  uiLabel * label1;</div><div class="line">  uiLabel * label2;</div><div class="line">  uiButton * button;</div><div class="line"></div><div class="line">  DownloadProgressFrame(uiFrame * parent)</div><div class="line">    : uiFrame(parent, <span class="stringliteral">&quot;Download&quot;</span>, Point(50, 100), Size(150, 110), false) {</div><div class="line">    frameProps().resizeable        = <span class="keyword">false</span>;</div><div class="line">    frameProps().moveable          = <span class="keyword">false</span>;</div><div class="line">    frameProps().hasCloseButton    = <span class="keyword">false</span>;</div><div class="line">    frameProps().hasMaximizeButton = <span class="keyword">false</span>;</div><div class="line">    frameProps().hasMinimizeButton = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">    label1 = <span class="keyword">new</span> uiLabel(<span class="keyword">this</span>, <span class="stringliteral">&quot;&quot;</span>, Point(10, 25));</div><div class="line">    label2 = <span class="keyword">new</span> uiLabel(<span class="keyword">this</span>, <span class="stringliteral">&quot;&quot;</span>, Point(10, 45));</div><div class="line">    button = <span class="keyword">new</span> uiButton(<span class="keyword">this</span>, <span class="stringliteral">&quot;Abort&quot;</span>, Point(50, 75), Size(50, 20));</div><div class="line">    button-&gt;onClick = [&amp;]() { exitModal(1); };</div><div class="line">  }</div><div class="line"></div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>HelpFame : <span class="keyword">public</span> uiFrame {</div><div class="line"></div><div class="line">  HelpFame(uiFrame * parent)</div><div class="line">    : uiFrame(parent, <span class="stringliteral">&quot;Help&quot;</span>, Point(50, 95), Size(160, 210), false) {</div><div class="line"></div><div class="line">    <span class="keyword">auto</span> button = <span class="keyword">new</span> uiButton(<span class="keyword">this</span>, <span class="stringliteral">&quot;OK&quot;</span>, Point(57, 180), Size(50, 20));</div><div class="line">    button-&gt;onClick = [&amp;]() { exitModal(0); };</div><div class="line"></div><div class="line">    onPaint = [&amp;]() {</div><div class="line">      Canvas.<a name="a0"></a><a class="code" href="classfabgl_1_1_canvas_class.html#aec16bab7318419fde24db0b9a78d3281">selectFont</a>(Canvas.<a name="a1"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a4ad927fd74aea835b15425fc4312361d">getPresetFontInfoFromHeight</a>(12, <span class="keyword">false</span>));</div><div class="line">      <span class="keywordtype">int</span> x = 10;</div><div class="line">      <span class="keywordtype">int</span> y = 10;</div><div class="line">      Canvas.<a name="a2"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(0, 2, 0));</div><div class="line">      Canvas.<a name="a3"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;Keyboard Shortcuts:&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(0, 0, 0));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   F12: Switch Emulator and Menu&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   DEL: Delete File or Folder&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   ALT + A-S-W-Z: Move Screen&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(0, 0, 2));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 18, <span class="stringliteral">&quot;\&quot;None\&quot; Joystick Mode:&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(0, 0, 0));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   ALT + MENU: Joystick Fire&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   ALT + CURSOR: Joystick Move&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(2, 0, 0));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 18, <span class="stringliteral">&quot;\&quot;Cursor Keys\&quot; Joystick Mode:&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(0, 0, 0));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   MENU: Joystick Fire&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(x, y += 14, <span class="stringliteral">&quot;   CURSOR: Joystick Move&quot;</span>);</div><div class="line">    };</div><div class="line">  }</div><div class="line"></div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">class </span>Menu : <span class="keyword">public</span> uiApp {</div><div class="line"></div><div class="line">  uiFileBrowser * fileBrowser;</div><div class="line">  uiComboBox *    RAMExpComboBox;</div><div class="line">  uiLabel *       WiFiStatusLbl;</div><div class="line">  uiLabel *       freeSpaceLbl;</div><div class="line"></div><div class="line">  <span class="keywordtype">void</span> init() {</div><div class="line">    rootWindow()-&gt;frameStyle().backgroundColor = RGB(3, 3, 3);</div><div class="line"></div><div class="line">    <span class="comment">// some static text</span></div><div class="line">    rootWindow()-&gt;onPaint = [&amp;]() {</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#aec16bab7318419fde24db0b9a78d3281">selectFont</a>(Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a4ad927fd74aea835b15425fc4312361d">getPresetFontInfoFromHeight</a>(12, <span class="keyword">false</span>));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(3, 1, 1));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(155, 345, <span class="stringliteral">&quot;V I C 2 0  Emulator&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a8dbddce234790b290cb4bd053dc0e701">setPenColor</a>(RGB(2, 1, 1));</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(167, 357, <span class="stringliteral">&quot;www.fabgl.com&quot;</span>);</div><div class="line">      Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(141, 369, <span class="stringliteral">&quot;2019 by Fabrizio Di Vittorio&quot;</span>);</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// programs list</span></div><div class="line">    fileBrowser = <span class="keyword">new</span> uiFileBrowser(rootWindow(), Point(5, 10), Size(140, 290));</div><div class="line">    fileBrowser-&gt;listBoxStyle().backgroundColor = RGB(0, 3, 0);</div><div class="line"></div><div class="line">    fileBrowser-&gt;listBoxStyle().selectedBackgroundColor = RGB(3, 0, 0);</div><div class="line">    fileBrowser-&gt;listBoxStyle().selectedBackgroundColor = RGB(2, 0, 0);</div><div class="line">    fileBrowser-&gt;listBoxStyle().focusedSelectedBackgroundColor = RGB(3, 0, 0);</div><div class="line">    fileBrowser-&gt;windowStyle().focusedBorderColor = RGB(3, 0, 0);</div><div class="line"></div><div class="line">    fileBrowser-&gt;listBoxStyle().focusedBackgroundColor = RGB(0, 3, 0);</div><div class="line">    fileBrowser-&gt;setDirectory(ROOTDIR);</div><div class="line">    fileBrowser-&gt;onChange = [&amp;]() {</div><div class="line">      setSelectedProgramConf();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// handles following keys:</span></div><div class="line">    <span class="comment">//   RETURN -&gt; load selected program and return to vic</span></div><div class="line">    fileBrowser-&gt;onKeyUp = [&amp;](uiKeyEventInfo key) {</div><div class="line">      <span class="keywordflow">if</span> (key.VK == <a name="a4"></a><a class="code" href="group___enumerations.html#ggae12c31a33f64281cba424d993a8a4381af2b3231b0f8f63c0ff09c727186d762b">VirtualKey::VK_RETURN</a>) {</div><div class="line">        <span class="keywordflow">if</span> (!fileBrowser-&gt;isDirectory() &amp;&amp; loadSelectedProgram())</div><div class="line">          runVIC20();</div><div class="line">      } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key.VK == <a name="a5"></a><a class="code" href="group___enumerations.html#ggae12c31a33f64281cba424d993a8a4381ab9780399c9a57c2bdcf4ee0ee5995589">VirtualKey::VK_DELETE</a>) {</div><div class="line">        <span class="comment">// delete file or directory</span></div><div class="line">        <span class="keywordflow">if</span> (messageBox(<span class="stringliteral">&quot;Delete Item&quot;</span>, <span class="stringliteral">&quot;Are you sure?&quot;</span>, <span class="stringliteral">&quot;Yes&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>) == uiMessageBoxResult::Button1) {</div><div class="line">          fileBrowser-&gt;content().remove( fileBrowser-&gt;filename() );</div><div class="line">          fileBrowser-&gt;update();</div><div class="line">          updateFreeSpaceLabel();</div><div class="line">        }</div><div class="line">      }</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// handles double click on program list</span></div><div class="line">    fileBrowser-&gt;onDblClick = [&amp;]() {</div><div class="line">      <span class="keywordflow">if</span> (!fileBrowser-&gt;isDirectory() &amp;&amp; loadSelectedProgram())</div><div class="line">        runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="keywordtype">int</span> x = 168;</div><div class="line"></div><div class="line">    <span class="comment">// &quot;Back to VIC&quot; button - run the VIC20</span></div><div class="line">    <span class="keyword">auto</span> VIC20Button = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Back to VIC&quot;</span>, Point(x, 10), Size(65, 19));</div><div class="line">    VIC20Button-&gt;onClick = [&amp;]() {</div><div class="line">      runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &quot;Load&quot; button</span></div><div class="line">    <span class="keyword">auto</span> loadButton = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Load&quot;</span>, Point(x, 35), Size(65, 19));</div><div class="line">    loadButton-&gt;onClick = [&amp;]() {</div><div class="line">      <span class="keywordflow">if</span> (loadSelectedProgram())</div><div class="line">        runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &quot;reset&quot; button</span></div><div class="line">    <span class="keyword">auto</span> resetButton = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Soft Reset&quot;</span>, Point(x, 60), Size(65, 19));</div><div class="line">    resetButton-&gt;onClick = [&amp;]() {</div><div class="line">      machine.reset();</div><div class="line">      runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &quot;Hard Reset&quot; button</span></div><div class="line">    <span class="keyword">auto</span> hresetButton = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Hard Reset&quot;</span>, Point(x, 85), Size(65, 19));</div><div class="line">    hresetButton-&gt;onClick = [&amp;]() {</div><div class="line">      machine.removeCRT();</div><div class="line">      machine.reset();</div><div class="line">      runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// &quot;help&quot; button</span></div><div class="line">    <span class="keyword">auto</span> helpButton = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Help&quot;</span>, Point(x, 282), Size(65, 19));</div><div class="line">    helpButton-&gt;onClick = [&amp;]() {</div><div class="line">      <span class="keyword">auto</span> hframe = <span class="keyword">new</span> HelpFame(rootWindow());</div><div class="line">      showModalWindow(hframe);</div><div class="line">      destroyWindow(hframe);</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// RAM expansion options</span></div><div class="line">    <span class="keywordtype">int</span> y = 120;</div><div class="line">    <span class="keyword">auto</span> lbl = <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;RAM Expansion:&quot;</span>, Point(150, y));</div><div class="line">    lbl-&gt;labelStyle().textColor = RGB(1, 1, 3);</div><div class="line">    RAMExpComboBox = <span class="keyword">new</span> uiComboBox(rootWindow(), Point(158, y + 20), Size(85, 19), 130);</div><div class="line">    <span class="keywordtype">char</span> <span class="keyword">const</span> * RAMOPTS[] = { <span class="stringliteral">&quot;Unexpanded&quot;</span>, <span class="stringliteral">&quot;3K&quot;</span>, <span class="stringliteral">&quot;8K&quot;</span>, <span class="stringliteral">&quot;16K&quot;</span>, <span class="stringliteral">&quot;24K&quot;</span>, <span class="stringliteral">&quot;27K (24K+3K)&quot;</span>, <span class="stringliteral">&quot;32K&quot;</span>, <span class="stringliteral">&quot;35K (32K+3K)&quot;</span> };</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 8; ++i)</div><div class="line">      RAMExpComboBox-&gt;items().append(RAMOPTS[i]);</div><div class="line">    RAMExpComboBox-&gt;selectItem((<span class="keywordtype">int</span>)machine.RAMExpansion());</div><div class="line">    RAMExpComboBox-&gt;onChange = [&amp;]() {</div><div class="line">      machine.setRAMExpansion((RAMExpansionOption)(RAMExpComboBox-&gt;selectedItem()));</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// joystick emulation options</span></div><div class="line">    y += 50;</div><div class="line">    lbl = <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;Joystick:&quot;</span>, Point(150, y));</div><div class="line">    lbl-&gt;labelStyle().textColor = RGB(1, 1, 3);</div><div class="line">    <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;None&quot;</span>, Point(180, y + 20));</div><div class="line">    <span class="keyword">auto</span> radioJNone = <span class="keyword">new</span> uiCheckBox(rootWindow(), Point(160, y + 20), Size(16, 16), uiCheckBoxKind::RadioButton);</div><div class="line">    <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;Cursor Keys&quot;</span>, Point(180, y + 40));</div><div class="line">    <span class="keyword">auto</span> radioJCurs = <span class="keyword">new</span> uiCheckBox(rootWindow(), Point(160, y + 40), Size(16, 16), uiCheckBoxKind::RadioButton);</div><div class="line">    <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;Mouse&quot;</span>, Point(180, y + 60));</div><div class="line">    <span class="keyword">auto</span> radioJMous = <span class="keyword">new</span> uiCheckBox(rootWindow(), Point(160, y + 60), Size(16, 16), uiCheckBoxKind::RadioButton);</div><div class="line">    radioJNone-&gt;setGroupIndex(1);</div><div class="line">    radioJCurs-&gt;setGroupIndex(1);</div><div class="line">    radioJMous-&gt;setGroupIndex(1);</div><div class="line">    radioJNone-&gt;setChecked(machine.joyEmu() == JE_None);</div><div class="line">    radioJCurs-&gt;setChecked(machine.joyEmu() == JE_CursorKeys);</div><div class="line">    radioJMous-&gt;setChecked(machine.joyEmu() == JE_Mouse);</div><div class="line">    radioJNone-&gt;onChange = [&amp;]() { machine.setJoyEmu(JE_None); };</div><div class="line">    radioJCurs-&gt;onChange = [&amp;]() { machine.setJoyEmu(JE_CursorKeys); };</div><div class="line">    radioJMous-&gt;onChange = [&amp;]() { machine.setJoyEmu(JE_Mouse); };</div><div class="line"></div><div class="line">    <span class="comment">// setup wifi button</span></div><div class="line">    <span class="keyword">auto</span> setupWifiBtn = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;Setup&quot;</span>, Point(28, 330), Size(40, 19));</div><div class="line">    setupWifiBtn-&gt;onClick = [&amp;]() {</div><div class="line">      <span class="keywordtype">char</span> SSID[32] = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line">      <span class="keywordtype">char</span> psw[32]  = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line">      <span class="keywordflow">if</span> (inputBox(<span class="stringliteral">&quot;WiFi Connect&quot;</span>, <span class="stringliteral">&quot;WiFi Name&quot;</span>, SSID, <span class="keyword">sizeof</span>(SSID), <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>) == uiMessageBoxResult::Button1 &amp;&amp;</div><div class="line">          inputBox(<span class="stringliteral">&quot;WiFi Connect&quot;</span>, <span class="stringliteral">&quot;Password&quot;</span>, psw, <span class="keyword">sizeof</span>(psw), <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>) == uiMessageBoxResult::Button1) {</div><div class="line">        fabgl::suspendInterrupts();</div><div class="line">        preferences.putString(<span class="stringliteral">&quot;SSID&quot;</span>, SSID);</div><div class="line">        preferences.putString(<span class="stringliteral">&quot;WiFiPsw&quot;</span>, psw);</div><div class="line">        fabgl::resumeInterrupts();</div><div class="line">      }</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// ON wifi button</span></div><div class="line">    <span class="keyword">auto</span> onWiFiBtn = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;On&quot;</span>, Point(72, 330), Size(40, 19));</div><div class="line">    onWiFiBtn-&gt;onClick = [&amp;]() {</div><div class="line">      connectWiFi();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// free space label</span></div><div class="line">    freeSpaceLbl = <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;&quot;</span>, Point(5, 305));</div><div class="line">    updateFreeSpaceLabel();</div><div class="line"></div><div class="line">    <span class="comment">// WiFi Status label</span></div><div class="line">    WiFiStatusLbl = <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;WiFi&quot;</span>, Point(5, 332));</div><div class="line">    WiFiStatusLbl-&gt;labelStyle().textColor = RGB(2, 2, 2);</div><div class="line"></div><div class="line">    <span class="comment">// &quot;Download From&quot; label</span></div><div class="line">    <span class="keyword">auto</span> downloadFromLbl = <span class="keyword">new</span> uiLabel(rootWindow(), <span class="stringliteral">&quot;Download From:&quot;</span>, Point(5, 354));</div><div class="line">    downloadFromLbl-&gt;labelStyle().textColor = RGB(1, 1, 3);</div><div class="line">    downloadFromLbl-&gt;labelStyle().textFont = Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a4ad927fd74aea835b15425fc4312361d">getPresetFontInfoFromHeight</a>(12, <span class="keyword">false</span>);</div><div class="line"></div><div class="line">    <span class="comment">// Download List button (download programs listed and linked in LIST_URL)</span></div><div class="line">    <span class="keyword">auto</span> downloadProgsBtn = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;List&quot;</span>, Point(75, 352), Size(27, 19));</div><div class="line">    downloadProgsBtn-&gt;onClick = [&amp;]() {</div><div class="line">      <span class="keywordflow">if</span> (!WiFiConnected()) {</div><div class="line">        messageBox(<span class="stringliteral">&quot;Network Error&quot;</span>, <span class="stringliteral">&quot;Please activate WiFi&quot;</span>, <span class="stringliteral">&quot;OK&quot;</span>, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>, uiMessageBoxIcon::Error);</div><div class="line">      } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (messageBox(<span class="stringliteral">&quot;Download Programs listed in \&quot;LIST_URL\&quot;&quot;</span>, <span class="stringliteral">&quot;Check your local laws for restrictions&quot;</span>, <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>, <span class="keyword">nullptr</span>, uiMessageBoxIcon::Warning) == uiMessageBoxResult::Button1) {</div><div class="line">        <span class="keyword">auto</span> pframe = <span class="keyword">new</span> DownloadProgressFrame(rootWindow());</div><div class="line">        <span class="keyword">auto</span> modalStatus = initModalWindow(pframe);</div><div class="line">        processModalWindowEvents(modalStatus, 100);</div><div class="line">        prepareForDownload();</div><div class="line">        <span class="keywordtype">char</span> * list = downloadList();</div><div class="line">        <span class="keywordtype">char</span> * plist = list;</div><div class="line">        <span class="keywordtype">int</span> count = countListItems(list);</div><div class="line">        <span class="keywordtype">int</span> dcount = 0;</div><div class="line">        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; count; ++i) {</div><div class="line">          <span class="keywordtype">char</span> <span class="keyword">const</span> * filename;</div><div class="line">          <span class="keywordtype">char</span> <span class="keyword">const</span> * URL;</div><div class="line">          plist = getNextListItem(plist, &amp;filename, &amp;URL);</div><div class="line">          pframe-&gt;label1-&gt;setText(filename);</div><div class="line">          <span class="keywordflow">if</span> (!processModalWindowEvents(modalStatus, 100))</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">          <span class="keywordflow">if</span> (downloadURL(URL, filename))</div><div class="line">            ++dcount;</div><div class="line">          pframe-&gt;label2-&gt;setTextFmt(<span class="stringliteral">&quot;Downloaded %d/%d&quot;</span>, dcount, count);</div><div class="line">        }</div><div class="line">        free(list);</div><div class="line">        <span class="comment">// modify &quot;abort&quot; button to &quot;OK&quot;</span></div><div class="line">        pframe-&gt;button-&gt;setText(<span class="stringliteral">&quot;OK&quot;</span>);</div><div class="line">        pframe-&gt;button-&gt;repaint();</div><div class="line">        <span class="comment">// wait for OK</span></div><div class="line">        processModalWindowEvents(modalStatus, -1);</div><div class="line">        endModalWindow(modalStatus);</div><div class="line">        destroyWindow(pframe);</div><div class="line">        fileBrowser-&gt;update();</div><div class="line">        updateFreeSpaceLabel();</div><div class="line">      }</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// Download from URL</span></div><div class="line">    <span class="keyword">auto</span> downloadURLBtn = <span class="keyword">new</span> uiButton(rootWindow(), <span class="stringliteral">&quot;URL&quot;</span>, Point(107, 352), Size(27, 19));</div><div class="line">    downloadURLBtn-&gt;onClick = [&amp;]() {</div><div class="line">      <span class="keywordtype">char</span> * URL = <span class="keyword">new</span> <span class="keywordtype">char</span>[128];</div><div class="line">      <span class="keywordtype">char</span> * filename = <span class="keyword">new</span> <span class="keywordtype">char</span>[25];</div><div class="line">      strcpy(URL, <span class="stringliteral">&quot;http://&quot;</span>);</div><div class="line">      <span class="keywordflow">if</span> (inputBox(<span class="stringliteral">&quot;Download From URL&quot;</span>, <span class="stringliteral">&quot;URL&quot;</span>, URL, 127, <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>) == uiMessageBoxResult::Button1) {</div><div class="line">        <span class="keywordtype">char</span> * lastslash = strrchr(URL, <span class="charliteral">&#39;/&#39;</span>);</div><div class="line">        <span class="keywordflow">if</span> (lastslash) {</div><div class="line">          strcpy(filename, lastslash + 1);</div><div class="line">          <span class="keywordflow">if</span> (inputBox(<span class="stringliteral">&quot;Download From URL&quot;</span>, <span class="stringliteral">&quot;Filename&quot;</span>, filename, 24, <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Cancel&quot;</span>) == uiMessageBoxResult::Button1) {</div><div class="line">            <span class="keywordflow">if</span> (downloadURL(URL, filename)) {</div><div class="line">              messageBox(<span class="stringliteral">&quot;Success&quot;</span>, <span class="stringliteral">&quot;Download OK!&quot;</span>, <span class="stringliteral">&quot;OK&quot;</span>, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>);</div><div class="line">              fileBrowser-&gt;update();</div><div class="line">              updateFreeSpaceLabel();</div><div class="line">            } <span class="keywordflow">else</span></div><div class="line">              messageBox(<span class="stringliteral">&quot;Error&quot;</span>, <span class="stringliteral">&quot;Download Failed!&quot;</span>, <span class="stringliteral">&quot;OK&quot;</span>, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>, uiMessageBoxIcon::Error);</div><div class="line">          }</div><div class="line">        }</div><div class="line">      }</div><div class="line">      <span class="keyword">delete</span> [] filename;</div><div class="line">      <span class="keyword">delete</span> [] URL;</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// process ESC and F12: boths run the emulator</span></div><div class="line">    rootWindow()-&gt;onKeyUp = [&amp;](uiKeyEventInfo key) {</div><div class="line">      <span class="keywordflow">if</span> (key.VK == <a name="a6"></a><a class="code" href="group___enumerations.html#ggae12c31a33f64281cba424d993a8a4381a7ba09580014424b5ebde799a85fe447d">VirtualKey::VK_ESCAPE</a> || key.VK == <a name="a7"></a><a class="code" href="group___enumerations.html#ggae12c31a33f64281cba424d993a8a4381a8aab073ab045a4732300d50ac40394db">VirtualKey::VK_F12</a>)</div><div class="line">        runVIC20();</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="comment">// focus on programs list</span></div><div class="line">    setFocusedWindow(fileBrowser);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// this is the main loop where VIC20 instructions are executed until F12 has been pressed</span></div><div class="line">  <span class="keywordtype">void</span> runVIC20()</div><div class="line">  {</div><div class="line">    enableKeyboardAndMouseEvents(<span class="keyword">false</span>);</div><div class="line">    Keyboard.<a name="a8"></a><a class="code" href="classfabgl_1_1_keyboard_class.html#a3d430ea3eeaeaa6fbf57fb534e640bf6">emptyVirtualKeyQueue</a>();</div><div class="line">    machine.VIC().enableAudio(<span class="keyword">true</span>);</div><div class="line">    Canvas.<a name="a9"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a9cec8cd2eb3f498b67ec7f20800131da">setBrushColor</a>(0, 0, 0);</div><div class="line">    Canvas.<a name="a10"></a><a class="code" href="classfabgl_1_1_canvas_class.html#a37beec4d52526d2710d47d911a1cd8c2">clear</a>();</div><div class="line"></div><div class="line">    <span class="keywordtype">bool</span> run = <span class="keyword">true</span>;</div><div class="line">    <span class="keywordflow">while</span> (run) {</div><div class="line"></div><div class="line"><span class="preprocessor">      #if DEBUG</span></div><div class="line">        <span class="keywordtype">int</span> cycles = machine.run();</div><div class="line">        <span class="keywordflow">if</span> (restart) {</div><div class="line">          scycles = cycles;</div><div class="line">          restart = <span class="keyword">false</span>;</div><div class="line">        } <span class="keywordflow">else</span></div><div class="line">          scycles += cycles;</div><div class="line"><span class="preprocessor">      #else</span></div><div class="line">        machine.run();</div><div class="line"><span class="preprocessor">      #endif</span></div><div class="line"></div><div class="line">      <span class="comment">// read keyboard</span></div><div class="line">      <span class="keywordflow">if</span> (Keyboard.<a name="a11"></a><a class="code" href="classfabgl_1_1_keyboard_class.html#aa93820f1c8f447a37c01376a8d6dbba0">virtualKeyAvailable</a>()) {</div><div class="line">        <span class="keywordtype">bool</span> keyDown;</div><div class="line">        <a name="a12"></a><a class="code" href="group___enumerations.html#gae12c31a33f64281cba424d993a8a4381">VirtualKey</a> vk = Keyboard.<a name="a13"></a><a class="code" href="classfabgl_1_1_keyboard_class.html#ae5bcb0c200a35ece54ecdf4cd47e49d6">getNextVirtualKey</a>(&amp;keyDown);</div><div class="line">        <span class="keywordflow">switch</span> (vk) {</div><div class="line"></div><div class="line">          <span class="comment">// F12 - stop running</span></div><div class="line">          <span class="keywordflow">case</span> <a class="code" href="group___enumerations.html#ggae12c31a33f64281cba424d993a8a4381a8aab073ab045a4732300d50ac40394db">VirtualKey::VK_F12</a>:</div><div class="line">            <span class="keywordflow">if</span> (!keyDown)</div><div class="line">              run = <span class="keyword">false</span>;  <span class="comment">// exit loop</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">          <span class="comment">// other keys</span></div><div class="line">          <span class="keywordflow">default</span>:</div><div class="line">            <span class="comment">// send to emulated machine</span></div><div class="line">            machine.setKeyboard(vk, keyDown);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">      }</div><div class="line"></div><div class="line">    }</div><div class="line">    machine.VIC().enableAudio(<span class="keyword">false</span>);</div><div class="line">    Keyboard.<a class="code" href="classfabgl_1_1_keyboard_class.html#a3d430ea3eeaeaa6fbf57fb534e640bf6">emptyVirtualKeyQueue</a>();</div><div class="line">    enableKeyboardAndMouseEvents(<span class="keyword">true</span>);</div><div class="line">    rootWindow()-&gt;repaint();</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// extract required RAM size from selected filename (a space and 3K, 8K...)</span></div><div class="line">  <span class="keywordtype">void</span> setSelectedProgramConf()</div><div class="line">  {</div><div class="line">    <span class="keywordtype">char</span> <span class="keyword">const</span> * fname = fileBrowser-&gt;filename();</div><div class="line">    <span class="keywordflow">if</span> (fname) {</div><div class="line">      <span class="comment">// select required memory expansion</span></div><div class="line">      <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span> * EXP[8] = { <span class="stringliteral">&quot;&quot;</span>, <span class="stringliteral">&quot; 3K&quot;</span>, <span class="stringliteral">&quot; 8K&quot;</span>, <span class="stringliteral">&quot; 16K&quot;</span>, <span class="stringliteral">&quot; 24K&quot;</span>, <span class="stringliteral">&quot; 27K&quot;</span>, <span class="stringliteral">&quot; 32K&quot;</span>, <span class="stringliteral">&quot; 35K&quot;</span> };</div><div class="line">      <span class="keywordtype">int</span> r = 0;</div><div class="line">      <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; 8; ++i)</div><div class="line">        <span class="keywordflow">if</span> (strstr(fname, EXP[i])) {</div><div class="line">          r = i;</div><div class="line">          <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">      RAMExpComboBox-&gt;selectItem(r);</div><div class="line">    }</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// extract address from selected filename. &quot;20&quot;=0x2000, &quot;40&quot;=0x4000, &quot;60&quot;=0x6000 or &quot;A0&quot;=0xA000, &quot;A0&quot; or automatic is the default</span></div><div class="line">  <span class="comment">// addrPos if specified will contain where address has been found</span></div><div class="line">  <span class="keywordtype">int</span> getAddress(<span class="keywordtype">char</span> * filename, <span class="keywordtype">char</span> * * addrPos = <span class="keyword">nullptr</span>)</div><div class="line">  {</div><div class="line">    <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span> * ASTR[] = { <span class="stringliteral">&quot; 20&quot;</span>, <span class="stringliteral">&quot; 40&quot;</span>, <span class="stringliteral">&quot; 60&quot;</span>, <span class="stringliteral">&quot; a0&quot;</span>, <span class="stringliteral">&quot; A0&quot;</span> };</div><div class="line">    <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span>    ADDR[] = { 0x2000, 0x4000, 0x6000, 0xa000, 0xa000 };</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <span class="keyword">sizeof</span>(ADDR) / <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>); ++i) {</div><div class="line">      <span class="keyword">auto</span> p = strstr(filename, ASTR[i]);</div><div class="line">      <span class="keywordflow">if</span> (p) {</div><div class="line">        <span class="keywordflow">if</span> (addrPos)</div><div class="line">          *addrPos = p + 1;</div><div class="line">        <span class="keywordflow">return</span> ADDR[i];</div><div class="line">      }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> -1;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// configuration given by filename:</span></div><div class="line">  <span class="comment">//    PROGNAME[EXP][ADDRESS].EXT</span></div><div class="line">  <span class="comment">//      PROGNAME : program name (not included extension)</span></div><div class="line">  <span class="comment">//      EXP      : expansion (&quot;3K&quot;, &quot;8K&quot;, &quot;16K&quot;, &quot;24K&quot;, &quot;27K&quot;, &quot;32K&quot;, &quot;35K&quot;)</span></div><div class="line">  <span class="comment">//      ADDRESS  : hex address (&quot;20&quot;=0x2000, &quot;40&quot;=0x4000, &quot;60&quot;=0x6000 or &quot;A0&quot;=0xA000), &quot;A0&quot; or automatic is the default</span></div><div class="line">  <span class="comment">//      EXT      : &quot;CRT&quot; or &quot;PRG&quot;</span></div><div class="line">  <span class="keywordtype">bool</span> loadSelectedProgram()</div><div class="line">  {</div><div class="line">    <span class="keywordtype">bool</span> backToVIC = <span class="keyword">false</span>;</div><div class="line">    <span class="keywordtype">char</span> <span class="keyword">const</span> * fname = fileBrowser-&gt;filename();</div><div class="line">    <span class="keywordflow">if</span> (fname) {</div><div class="line">      FileBrowser &amp; dir  = fileBrowser-&gt;content();</div><div class="line"></div><div class="line">      <span class="keywordtype">bool</span> isPRG = strstr(fname, <span class="stringliteral">&quot;.PRG&quot;</span>) || strstr(fname, <span class="stringliteral">&quot;.prg&quot;</span>);</div><div class="line">      <span class="keywordtype">bool</span> isCRT = strstr(fname, <span class="stringliteral">&quot;.CRT&quot;</span>) || strstr(fname, <span class="stringliteral">&quot;.crt&quot;</span>);</div><div class="line"></div><div class="line">      <span class="keywordflow">if</span> (isPRG || isCRT) {</div><div class="line"></div><div class="line">        machine.removeCRT();</div><div class="line"></div><div class="line">        <span class="keywordtype">int</span> fullpathlen = dir.getFullPath(fname);</div><div class="line">        <span class="keywordtype">char</span> fullpath[fullpathlen];</div><div class="line">        dir.getFullPath(fname, fullpath, fullpathlen);</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (isPRG) {</div><div class="line">          <span class="comment">// this is a PRG, just reset, load and run</span></div><div class="line">          machine.loadPRG(fullpath, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line">        } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (isCRT) {</div><div class="line">          <span class="comment">// this a CRT, find other parts, load and reset</span></div><div class="line">          <span class="keywordtype">char</span> * addrPos = <span class="keyword">nullptr</span>;</div><div class="line">          <span class="keywordtype">int</span> addr = getAddress(fullpath, &amp;addrPos);</div><div class="line">          <span class="keywordflow">if</span> (addrPos) {</div><div class="line">            <span class="comment">// address specified, try to load all possible positions (2000, 4000, 6000 and a000)</span></div><div class="line">            <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * POS = { <span class="stringliteral">&quot;246Aa&quot;</span> }; <span class="comment">// 2=2000, 4=4000, 6=6000, A=a000</span></div><div class="line">            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <span class="keyword">sizeof</span>(POS); ++i) {</div><div class="line">              *addrPos = POS[i];  <span class="comment">// actually replaces char inside &quot;fullpath&quot;</span></div><div class="line">              machine.loadCRT(fullpath, <span class="keyword">true</span>, getAddress(fullpath));</div><div class="line">            }</div><div class="line">          } <span class="keywordflow">else</span> {</div><div class="line">            <span class="comment">// no address specified, just load it</span></div><div class="line">            machine.loadCRT(fullpath, <span class="keyword">true</span>, addr);</div><div class="line">          }</div><div class="line">        }</div><div class="line">        backToVIC = <span class="keyword">true</span>;</div><div class="line">      }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> backToVIC;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// return true if WiFi is connected</span></div><div class="line">  <span class="keywordtype">bool</span> WiFiConnected() {</div><div class="line">    fabgl::suspendInterrupts();</div><div class="line">    <span class="keywordtype">bool</span> r = WiFi.status() == WL_CONNECTED;</div><div class="line">    fabgl::resumeInterrupts();</div><div class="line">    <span class="keywordflow">return</span> r;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// connect to wifi using SSID and PSW from Preferences</span></div><div class="line">  <span class="keywordtype">void</span> connectWiFi()</div><div class="line">  {</div><div class="line">    fabgl::suspendInterrupts();</div><div class="line">    <span class="keywordtype">char</span> SSID[32], psw[32];</div><div class="line">    <span class="keywordflow">if</span> (preferences.getString(<span class="stringliteral">&quot;SSID&quot;</span>, SSID, <span class="keyword">sizeof</span>(SSID)) &amp;&amp; preferences.getString(<span class="stringliteral">&quot;WiFiPsw&quot;</span>, psw, <span class="keyword">sizeof</span>(psw))) {</div><div class="line">      WiFi.begin(SSID, psw);</div><div class="line">      <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 6 &amp;&amp; WiFi.status() != WL_CONNECTED; ++i) {</div><div class="line">        WiFi.reconnect();</div><div class="line">        delay(1000);</div><div class="line">      }</div><div class="line">    }</div><div class="line">    WiFiStatusLbl-&gt;labelStyle().textColor = (WiFi.status() == WL_CONNECTED ? RGB(0, 2, 0) : RGB(2, 2, 2));</div><div class="line">    WiFiStatusLbl-&gt;update();</div><div class="line">    fabgl::resumeInterrupts();</div><div class="line">    <span class="keywordflow">if</span> (WiFi.status() != WL_CONNECTED)</div><div class="line">      messageBox(<span class="stringliteral">&quot;Network Error&quot;</span>, <span class="stringliteral">&quot;Failed to connect WiFi. Try again!&quot;</span>, <span class="stringliteral">&quot;OK&quot;</span>, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>, uiMessageBoxIcon::Error);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// creates List folder and makes it current</span></div><div class="line">  <span class="keywordtype">void</span> prepareForDownload()</div><div class="line">  {</div><div class="line">    <span class="keyword">static</span> <span class="keywordtype">char</span> <span class="keyword">const</span> * DOWNDIR = <span class="stringliteral">&quot;List&quot;</span>;</div><div class="line">    FileBrowser &amp; dir = fileBrowser-&gt;content();</div><div class="line"></div><div class="line">    fabgl::suspendInterrupts();</div><div class="line">    dir.setDirectory(ROOTDIR);</div><div class="line">    dir.makeDirectory(DOWNDIR);</div><div class="line">    dir.changeDirectory(DOWNDIR);</div><div class="line">    fabgl::resumeInterrupts();</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// download list from LIST_URL</span></div><div class="line">  <span class="comment">// ret nullptr on fail</span></div><div class="line">  <span class="keywordtype">char</span> * downloadList()</div><div class="line">  {</div><div class="line">    fabgl::suspendInterrupts();</div><div class="line">    <span class="keyword">auto</span> list = (<span class="keywordtype">char</span>*) malloc(MAXLISTSIZE);</div><div class="line">    <span class="keyword">auto</span> dest = list;</div><div class="line">    HTTPClient http;</div><div class="line">    http.begin(LIST_URL);</div><div class="line">    <span class="keywordtype">int</span> httpCode = http.GET();</div><div class="line">    <span class="keywordflow">if</span> (httpCode == HTTP_CODE_OK) {</div><div class="line">      WiFiClient * stream = http.getStreamPtr();</div><div class="line">      <span class="keywordtype">int</span> bufspace = MAXLISTSIZE;</div><div class="line">      <span class="keywordflow">while</span> (http.connected() &amp;&amp; bufspace &gt; 1) {</div><div class="line">        <span class="keyword">auto</span> size = stream-&gt;available();</div><div class="line">        <span class="keywordflow">if</span> (size) {</div><div class="line">          <span class="keywordtype">int</span> c = stream-&gt;readBytes(dest, fabgl::imin(bufspace, size));</div><div class="line">          dest += c;</div><div class="line">          bufspace -= c;</div><div class="line">        }</div><div class="line">      }</div><div class="line">    }</div><div class="line">    *dest = 0;</div><div class="line">    fabgl::resumeInterrupts();</div><div class="line">    <span class="keywordflow">return</span> list;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// count number of items in download list</span></div><div class="line">  <span class="keywordtype">int</span> countListItems(<span class="keywordtype">char</span> <span class="keyword">const</span> * list)</div><div class="line">  {</div><div class="line">    <span class="keywordtype">int</span> count = 0;</div><div class="line">    <span class="keyword">auto</span> p = list;</div><div class="line">    <span class="keywordflow">while</span> (*p++)</div><div class="line">      <span class="keywordflow">if</span> (*p == 0x0a)</div><div class="line">        ++count;</div><div class="line">    <span class="keywordflow">return</span> (count + 1) / 3;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// extract filename and URL from downloaded list</span></div><div class="line">  <span class="keywordtype">char</span> * getNextListItem(<span class="keywordtype">char</span> * list, <span class="keywordtype">char</span> <span class="keyword">const</span> * * filename, <span class="keywordtype">char</span> <span class="keyword">const</span> * * URL)</div><div class="line">  {</div><div class="line">    <span class="comment">// bypass spaces</span></div><div class="line">    <span class="keywordflow">while</span> (*list == 0x0a || *list == 0x0d || *list == 0x20)</div><div class="line">      ++list;</div><div class="line">    <span class="comment">// get filename</span></div><div class="line">    *filename = list;</div><div class="line">    <span class="keywordflow">while</span> (*list &amp;&amp; *list != 0x0a &amp;&amp; *list != 0x0d)</div><div class="line">      ++list;</div><div class="line">    *list++ = 0;</div><div class="line">    <span class="comment">// bypass spaces</span></div><div class="line">    <span class="keywordflow">while</span> (*list &amp;&amp; (*list == 0x0a || *list == 0x0d || *list == 0x20))</div><div class="line">      ++list;</div><div class="line">    <span class="comment">// get URL</span></div><div class="line">    *URL = list;</div><div class="line">    <span class="keywordflow">while</span> (*list &amp;&amp; *list != 0x0a &amp;&amp; *list != 0x0d)</div><div class="line">      ++list;</div><div class="line">    *list++ = 0;</div><div class="line">    <span class="keywordflow">return</span> list;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// download specified filename from URL</span></div><div class="line">  <span class="keywordtype">bool</span> downloadURL(<span class="keywordtype">char</span> <span class="keyword">const</span> * URL, <span class="keywordtype">char</span> <span class="keyword">const</span> * filename)</div><div class="line">  {</div><div class="line">    fabgl::suspendInterrupts();</div><div class="line">    FileBrowser &amp; dir = fileBrowser-&gt;content();</div><div class="line">    <span class="keywordflow">if</span> (dir.exists(filename)) {</div><div class="line">      fabgl::resumeInterrupts();</div><div class="line">      <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordtype">bool</span> success = <span class="keyword">false</span>;</div><div class="line">    HTTPClient http;</div><div class="line">    http.begin(URL);</div><div class="line">    <span class="keywordtype">int</span> httpCode = http.GET();</div><div class="line">    <span class="keywordflow">if</span> (httpCode == HTTP_CODE_OK) {</div><div class="line"></div><div class="line">      <span class="keywordtype">int</span> fullpathLen = dir.getFullPath(filename);</div><div class="line">      <span class="keywordtype">char</span> fullpath[fullpathLen];</div><div class="line">      dir.getFullPath(filename, fullpath, fullpathLen);</div><div class="line">      FILE * f = fopen(fullpath, <span class="stringliteral">&quot;wb&quot;</span>);</div><div class="line"></div><div class="line">      <span class="keywordflow">if</span> (f) {</div><div class="line">        <span class="keywordtype">int</span> len = http.getSize();</div><div class="line">        uint8_t * buf = (uint8_t*) malloc(128);</div><div class="line">        WiFiClient * stream = http.getStreamPtr();</div><div class="line">        <span class="keywordtype">int</span> dsize = 0;</div><div class="line">        <span class="keywordflow">while</span> (http.connected() &amp;&amp; (len &gt; 0 || len == -1)) {</div><div class="line">          <span class="keywordtype">size_t</span> size = stream-&gt;available();</div><div class="line">          <span class="keywordflow">if</span> (size) {</div><div class="line">            <span class="keywordtype">int</span> c = stream-&gt;readBytes(buf, fabgl::imin(<span class="keyword">sizeof</span>(buf), size));</div><div class="line">            fwrite(buf, c, 1, f);</div><div class="line">            dsize += c;</div><div class="line">            <span class="keywordflow">if</span> (len &gt; 0)</div><div class="line">              len -= c;</div><div class="line">          }</div><div class="line">        }</div><div class="line">        free(buf);</div><div class="line">        fclose(f);</div><div class="line">        success = (len == 0 || (len == -1 &amp;&amp; dsize &gt; 0));</div><div class="line">      }</div><div class="line">    }</div><div class="line">    fabgl::resumeInterrupts();</div><div class="line">    <span class="keywordflow">return</span> success;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// show free SPIFFS space</span></div><div class="line">  <span class="keywordtype">void</span> updateFreeSpaceLabel() {</div><div class="line">    <span class="keywordtype">size_t</span> total = 0, used = 0;</div><div class="line">    esp_spiffs_info(NULL, &amp;total, &amp;used);</div><div class="line">    freeSpaceLbl-&gt;setTextFmt(<span class="stringliteral">&quot;%d KB Free&quot;</span>, (total - used) / 1024);</div><div class="line">    freeSpaceLbl-&gt;update();</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setup()</div><div class="line">{</div><div class="line">  Serial.begin(115200); <span class="comment">// for debug purposes</span></div><div class="line"></div><div class="line">  preferences.begin(<span class="stringliteral">&quot;VIC20&quot;</span>, <span class="keyword">false</span>);</div><div class="line"></div><div class="line">  PS2Controller.<a name="a14"></a><a class="code" href="classfabgl_1_1_p_s2_controller_class.html#a7082e498e95fd5f5a4edfbe73923f397">begin</a>(PS2Preset::KeyboardPort0_MousePort1, KbdMode::CreateVirtualKeysQueue);</div><div class="line">  Keyboard.<a name="a15"></a><a class="code" href="classfabgl_1_1_keyboard_class.html#a08b281a865847dfc514b2f0c7d77e095">setLayout</a>(&amp;fabgl::UKLayout);</div><div class="line"></div><div class="line">  VGAController.<a name="a16"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#acdc8b95372c01a76deeb4abe360d0295">begin</a>();</div><div class="line">  VGAController.<a name="a17"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#ac190a844ead4bb68817c733fb0c9a5af">setResolution</a>(<a name="a18"></a><a class="code" href="fabglconf_8h.html#a79c16e345febd0d26723e122a4b939b4">VGA_256x384_60Hz</a>);</div><div class="line">  VGAController.<a name="a19"></a><a class="code" href="classfabgl_1_1_v_g_a_controller_class.html#ae667203ac63d3c59b975f5cc862a61b9">enableBackgroundPrimitiveTimeout</a>(<span class="keyword">false</span>);</div><div class="line"></div><div class="line">  <span class="comment">// adjust this to center screen in your monitor</span></div><div class="line">  <span class="comment">//VGAController.moveScreen(20, -2);</span></div><div class="line"></div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#aec16bab7318419fde24db0b9a78d3281">selectFont</a>(Canvas.<a name="a20"></a><a class="code" href="classfabgl_1_1_canvas_class.html#aae47e5f03e69ed21dd07f4b73e43e4f0">getPresetFontInfo</a>(32, 48));</div><div class="line"></div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a37beec4d52526d2710d47d911a1cd8c2">clear</a>();</div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(25, 10, <span class="stringliteral">&quot;Initializing SPIFFS...&quot;</span>);</div><div class="line">  Canvas.<a name="a21"></a><a class="code" href="classfabgl_1_1_canvas_class.html#ad2f55393ab2f38be5779fd8651979cca">waitCompletion</a>();</div><div class="line">  initSPIFFS();</div><div class="line"></div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#a7e53c87e27387e1849e9439880d03e44">drawText</a>(25, 30, <span class="stringliteral">&quot;Copying embedded programs...&quot;</span>);</div><div class="line">  Canvas.<a class="code" href="classfabgl_1_1_canvas_class.html#ad2f55393ab2f38be5779fd8651979cca">waitCompletion</a>();</div><div class="line">  copyEmbeddedPrograms();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop()</div><div class="line">{</div><div class="line"><span class="preprocessor">  #if DEBUG</span></div><div class="line">  TimerHandle_t xtimer = xTimerCreate(<span class="stringliteral">&quot;&quot;</span>, pdMS_TO_TICKS(5000), pdTRUE, (<span class="keywordtype">void</span>*)0, vTimerCallback1SecExpired);</div><div class="line">  xTimerStart(xtimer, 0);</div><div class="line"><span class="preprocessor">  #endif</span></div><div class="line"></div><div class="line">  <span class="keyword">auto</span> menu = <span class="keyword">new</span> Menu;</div><div class="line">  menu-&gt;run();</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
